package com.orange.lswidget.widgets.musicplayer.entry;

public class TrackInfo {

	public String	mTrackName;
	public long		mAudioId;
	public String	mArtistName;
	public String	mAlbumName;
	public long		mAlbumId;
	public long		mPosition;
	public long		mDuration;

	public TrackInfo(long id, String track, String album, long albumId,
			String artist, long position, long duration) {
		mAudioId = id;
		mTrackName = track;
		mAlbumName = album;
		mAlbumId = albumId;
		mArtistName = artist;
		mPosition = position;
		mDuration = duration;
	}

	@Override
	public String toString() {
		return String
				.format("\n%-15s: %d\n%-15s: %s\n%-15s: %s\n%-15s: %d\n%-15s: %s\n%-15s: %d(%s)\n%-15s: %d(%s)",
						"Audio ID", mAudioId, "Track", mTrackName, "Album",
						mAlbumName, "Album ID", mAlbumId, "Artist",
						mArtistName, "Position", mPosition,
						timeToString(mPosition), "Duration", mDuration,
						timeToString(mDuration));
	}

	public static String timeToString(long time) {
		int hour = (int) (time / 3600);
		long minute = (time % 3600) / 60;
		long second = (time % 60);

		String timestr = null;

		if (hour == 0) {
			timestr = String.format("%02d:%02d", minute, second);
		} else {
			timestr = String.format("%d:%02d:%02d", hour, minute, second);
		}

		return timestr;
	}

}
